@echo off
setlocal
set "FRONT=%~dp0Display-ANR-DATE\frontend"

echo [ANR] Frontend dir: %FRONT%
if not exist "%FRONT%" goto :dir_err

where node >nul 2>nul
if errorlevel 1 goto :node_err
where npm >nul 2>nul
if errorlevel 1 goto :node_err

cd /d "%FRONT%"
if errorlevel 1 goto :dir_err

if not exist node_modules (
  echo [ANR] Installing dependencies (npm install)...
  call npm install
  if errorlevel 1 goto :npm_err
)

echo [ANR] Starting Vite dev server?host/port ? vite.config.js ??: 10.240.6.34:3000?
call npm run dev
goto :eof

:dir_err
echo [ANR] Frontend directory not found.
pause
exit /b 1

:node_err
echo [ANR] Node.js/npm not found in PATH. Please install Node.js.
pause
exit /b 1

:npm_err
echo [ANR] npm install failed.
pause
exit /b 1
